************************************************************************
************************************************************************
*******This do.file produces the results reported in table OA.3.1*******
************************************************************************
************************************************************************

set more off
svyset [pw=WT_NATION]

set more off

***** recode variables 

**american id

gen amerid1=AMERICAN
recode amerid1(5 6 =.)
summ amerid1
gen amerid=(amerid1-1)/3 

**latino id

gen latid1=LAIDENT
recode latid1 (5 6 =.)
summ latid1 
gen latid=(latid1-1)/3

summ amerid latid

pwcorr amerid latid, sig
polychoric amerid latid


** immersion - "english only" in schools

gen immersion1=IMMERSN
recode immersion1(5=.)
gen immersion=(immersion1-1)/3

**blend vs. remain distinct

gen maintain=DISTINCT
recode maintain(4 5 =.)

gen blend=BLEND
recode blend(4 5 =.)
summ blend

gen relblend=(blend-maintain)
summ relblend

**pro-latino preferences

gen latcand=PREFLAT
gen latspan=PREFSPAN

polychoric latcand latspan

gen prolat1=(latcand+latspan)
summ prolat1
gen prolat=(prolat1-2)/4
summ prolat

**age

rename BIRDATE birthyr

gen age=.
replace age=18 if birthyr==1988
replace age=19 if birthyr==1987
replace age=20 if birthyr==1986
replace age=21 if birthyr==1985
replace age=22 if birthyr==1984
replace age=23 if birthyr==1983
replace age=24 if birthyr==1982
replace age=25 if birthyr==1981
replace age=26 if birthyr==1980
replace age=27 if birthyr==1979
replace age=28 if birthyr==1978
replace age=29 if birthyr==1977
replace age=30 if birthyr==1976
replace age=31 if birthyr==1975
replace age=32 if birthyr==1974
replace age=33 if birthyr==1973
replace age=34 if birthyr==1972
replace age=35 if birthyr==1971
replace age=36 if birthyr==1970
replace age=37 if birthyr==1969
replace age=38 if birthyr==1968
replace age=39 if birthyr==1967
replace age=40 if birthyr==1966
replace age=41 if birthyr==1965
replace age=42 if birthyr==1964
replace age=43 if birthyr==1963
replace age=44 if birthyr==1962
replace age=45 if birthyr==1961
replace age=46 if birthyr==1960
replace age=47 if birthyr==1959
replace age=48 if birthyr==1958
replace age=49 if birthyr==1957
replace age=50 if birthyr==1956
replace age=51 if birthyr==1955
replace age=52 if birthyr==1954
replace age=53 if birthyr==1953
replace age=54 if birthyr==1952
replace age=55 if birthyr==1951
replace age=56 if birthyr==1950
replace age=57 if birthyr==1949
replace age=58 if birthyr==1948
replace age=59 if birthyr==1947
replace age=60 if birthyr==1946
replace age=61 if birthyr==1945
replace age=62 if birthyr==1944
replace age=63 if birthyr==1943
replace age=64 if birthyr==1942
replace age=65 if birthyr==1941
replace age=66 if birthyr==1940
replace age=67 if birthyr==1939
replace age=68 if birthyr==1938
replace age=69 if birthyr==1937
replace age=70 if birthyr==1936
replace age=71 if birthyr==1935
replace age=72 if birthyr==1934
replace age=73 if birthyr==1933
replace age=74 if birthyr==1932
replace age=75 if birthyr==1931
replace age=76 if birthyr==1930
replace age=77 if birthyr==1929
replace age=78 if birthyr==1928
replace age=79 if birthyr==1927
replace age=80 if birthyr==1926
replace age=81 if birthyr==1925
replace age=82 if birthyr==1924
replace age=83 if birthyr==1923
replace age=84 if birthyr==1922
replace age=85 if birthyr==1921
replace age=86 if birthyr==1920
replace age=87 if birthyr==1919
replace age=88 if birthyr==1918
replace age=89 if birthyr==1917
replace age=90 if birthyr==1916
replace age=91 if birthyr==1915
replace age=92 if birthyr==1914
replace age=93 if birthyr==1913
replace age=94 if birthyr==1912
replace age=95 if birthyr==1911
replace age=96 if birthyr==1910
replace age=97 if birthyr==1909
replace age=98 if birthyr==1908
replace age= -9999 if birthyr==9999

summ age
recode age -9999=.
summ age
recode age .=41
summ age
gen edad=(age-19)/79
summ edad 

**education 

rename REDUC educ
tab educ 
gen educa=(educ/7)

**employed

rename EMPSTAT empstat
gen employed=0
recode employed 0=1 if empstat==1
tab employed

**own a home

rename HOMEOWN ownhome2
gen ownhome=0
recode ownhome 0=1 if ownhome2==1
tab ownhome

**female

rename SEX female
tab female
recode female (2=1)(1=0)
tab female, nolabel

**married

rename MARITAL marital
gen married=0
recode married 0=1 if marital==4
tab married

**party 

recode PARTYID (1=1)(2 3 4 5 = 0), gen(dem)
recode PARTYID (2=1)(1 3 4 5 = 0), gen(rep)
recode PARTYID (3=1)(1 2 4 5 = 0), gen(ind)

**ideology 

recode IDEOLOGY (1=1)(else = 0), gen(con)
recode IDEOLOGY (2=1)(else = 0), gen(lib)
recode IDEOLOGY (3=1)(else = 0), gen(mod)

**generation status variables

**second and third, where second = second generation, and third = third generation

**coding notes: 1st=foreign born; 2nd=native born with 1-2 foreign born parents; 3rd=native-born with native-born parents

rename PARBORN parborn
recode parborn (4=.)(5=.)

rename BORNUS native
tab native

tab native parborn

gen foreign=.
recode foreign .=0 if native==1
recode foreign .=0 if native==2
recode foreign .=1 if native==3
tab foreign

gen second=0
recode second (0=1) if native==1 & parborn==1
recode second (0=1) if native==1 & parborn==3
recode second (0=1) if native==2 & parborn==1
recode second (0=1) if native==2 & parborn==3

gen third=0
recode third (0=1) if native==1 & parborn==2 
recode third (0=1) if native==2 & parborn==2

**citizen 

rename NATUSCIT natural
gen citiz=0
recode citiz (0=1) if natural==1
tab citiz, nolabel


**cuban, puerto rican, salvadoran, dominican, with mexicans et al. as omitted category

rename ANCESTRY ancestry
tab ancestry

gen cuban=.
recode cuban .=1 if ancestry==6
recode cuban .=0 if ancestry==7
recode cuban .=0 if ancestry==9
recode cuban .=0 if ancestry==12
recode cuban .=0 if ancestry==17
tab cuban, nolabel

gen puerto=.
recode puerto .=1 if ancestry==17
recode puerto .=0 if ancestry==6
recode puerto .=0 if ancestry==7
recode puerto .=0 if ancestry==9
recode puerto .=0 if ancestry==12
tab puerto, nolabel

gen dominic=.
recode dominic .=1 if ancestry==7
recode dominic .=0 if ancestry==6
recode dominic .=0 if ancestry==9
recode dominic .=0 if ancestry==12
recode dominic .=0 if ancestry==17
tab dominic, nolabel

gen salva=.
recode salva .=1 if ancestry==9
recode salva .=0 if ancestry==6
recode salva .=0 if ancestry==7
recode salva .=0 if ancestry==12
recode salva .=0 if ancestry==17
tab salva, nolabel

******analysis******

reg relblend latid amerid dem rep ind lib con mod  edad educa employed ownhome female married second third citiz cuban puerto salva dominic [pweight = WT_NATION]
est store blendintosoc

reg prolat latid amerid dem rep ind lib con mod  edad educa employed ownhome female married second third citiz cuban puerto salva dominic [pweight = WT_NATION]
est store prolat

reg immersion latid amerid dem rep ind lib con mod  edad educa employed ownhome female married second third citiz cuban puerto salva dominic [pweight = WT_NATION]
est store engonly

est table blendintosoc prolat engonly ,  b(%9.3f) star(.1 .05 .01) stats(N) eq(1)
est table blendintosoc prolat engonly ,  b(%9.3f) se(%9.3f) stats(N) eq(1)


